#ifndef SQLCONNECTION_H_
#define SQLCONNECTION_H_

#include<my_header.h>
#include<mysql/mysql.h>

#define MAX_CONN_NUM 100

typedef struct sql_connect_s
{
    MYSQL _connect;
    int _useFlag;//判断是否被使用
    int _connsIndex;//连接编号
} sqlConnection;

typedef struct sqlConnectPool_s
{
	sqlConnection *_connections;//连接数组
    int _connNum;//连接数量
    pthread_mutex_t _sqlMutex;
    pthread_cond_t _sqlCond;
}sqlConnectPool;

//初始化连接池
int initSqlConnectPool(sqlConnectPool *pool, const char *host,
		       const char *user, const char *password,
		       const char *database, int connNum);
//摧毁连接池
void destroySqlConnectPool(sqlConnectPool *pool);

//获取一个连接
sqlConnection *getConnection(sqlConnectPool *pool);
//释放一个连接
void releaseConnection(sqlConnectPool *pool, sqlConnection *conn);

#endif		 	